package zouran.controller;

import org.springframework.web.bind.annotation.*;
import zouran.entity.intentityimg.Eclipeser;
import zouran.result.ResultMap;
import zouran.service.EconomiclossService;

import java.util.Map;

@RestController
@RequestMapping("/economyloss")
public class EconomiclossController {

    private final EconomiclossService economiclossService;

    private final ResultMap<Eclipeser> resultMap;

    public EconomiclossController(EconomiclossService economiclossService, ResultMap<Eclipeser> resultMap){
        this.economiclossService = economiclossService;
        this.resultMap = resultMap;
    }

    @GetMapping("/getAllstructure")
    public ResultMap getListall(){
        return resultMap.success(economiclossService.getListall());
    }

    @GetMapping("/price")
    public ResultMap getPriceBycity(@RequestParam String city){
        return resultMap.success(economiclossService.getPriceBycity(city));
    }

    @PostMapping("/getmainstructpara")
    public ResultMap getmainpara(@RequestBody Map<String, Object> request) {
        int index = (Integer) request.get("index");
        if (index == 0){
            return resultMap.success(economiclossService.getnewfun(request));
        }
       else {
           return resultMap.success(economiclossService.getnewfun1(request));
        }
    }
    @GetMapping("/getbaseall")
    public ResultMap getbaseall(){
        return resultMap.success(economiclossService.getbaseAll());
    }

//    计算内外层半径
    @PostMapping("/computedr")
    public ResultMap computedr(@RequestBody Eclipeser eclipeser){
        return resultMap.success(economiclossService.geteclipser(eclipeser));
    }

}
